﻿//
//  HFHttpJustGetFactory.m
//  AFNetworking
//
//  Created by Points on 2020/4/21.
//

#import "HFHttpJustGetFactory.h"

@implementation HFHttpJustGetFactory

- (id<HFHttpAbstractFactory> (^)(void))get{
      __block __weak typeof(self) weakSelf = self;
     return ^(void){
         if (self.rsaEncryptResult) {
             BOOL needToast = weakSelf.needToast;
             HFHttpSucceedBlock successBlock = weakSelf.mSucceedBlock;
             HFHttpFailedBlock failBlock = weakSelf.mFailedBlock;
             NSDictionary *para = weakSelf.mPara;
             NSURLSessionTask *task = [HFBaseHTTPRequestManager HTGET:weakSelf.mPath parameters:weakSelf.mPara success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
                 [HFHttpJustGetFactory requestSuccessWithTask:task
                                                          body:para
                                                responseObject:responseObject
                                                successHandler:successBlock
                                                     needToast:needToast
                                                     rsaSwitch:weakSelf.rsaSwitch];
             } failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
                 [HFHttpJustGetFactory requestFailureWithTask:task
                                                         param:weakSelf.mPara
                                                         error:error
                                                failureHandler:failBlock
                                                     needToast:needToast];
             }];
             [weakSelf startDelayTimer:task];
         }
         
         return weakSelf;
     };
}

@end

